package kr.hkit.androidcomplete03.ch21;

import kr.hkit.androidcomplete03.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.ShareActionProvider;
import android.widget.TextView;

public class ShareAction extends Activity {
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		TextView tv=new TextView(this);
		tv.setText("공유 액션 프로바이더를 테스트합니다.");
		setContentView(tv);
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		 super.onCreateOptionsMenu(menu);
		 MenuInflater inflater=getMenuInflater();
		 inflater.inflate(R.menu.shareactionmenu, menu);
		 
		 Intent intent=new Intent(Intent.ACTION_SEND);
		 intent.setType("text/plain"); //일반적인 텍스트
		 intent.putExtra(Intent.EXTRA_TEXT, "sharing text");
		 
		 MenuItem share=menu.findItem(R.id.share);
		 ShareActionProvider provider=(ShareActionProvider)share.getActionProvider();
		 provider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
		 provider.setShareIntent(intent);
		 
		 MenuItem sharemenu=menu.findItem(R.id.sharemenu);
		 ShareActionProvider providermenu=(ShareActionProvider)sharemenu.getActionProvider();
		 providermenu.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
		 providermenu.setShareIntent(intent);
		 
		 return true;
		 
		 
		 
	}
}
